package example.com.terry.servlet;

import example.com.terry.utils.CookieUtils;
import example.com.terry.utils.JDBCUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * ClassName: QueryWorkServlet <br/>
 * Description: 作业状态修改 <br/>
 * Date: 2020/5/21 下午5:27 <br/>
 * <br/>
 *
 * @author ls
 * <p/>
 * 修改记录
 * @version 1.0<br />
 */
@WebServlet("/updateWorkServlet")
public class UpdateWorkServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        if (CookieUtils.isSign(req)) {
            String type = req.getParameter("type");
            String id = req.getParameter("id");

            String sql = "update tb_work set type ='" + type + "' where id = '" + id + "'";
            boolean init = JDBCUtils.init(sql);
            if (init) {
                resp.getWriter().println("修改作业记录状态成功");
            } else {
                resp.getWriter().println("修改作业记录状态失败");
            }

        }
    }
}
